from tinkoff.invest import Client, RequestError
from sqlalchemy import create_engine, Table, Column, String, MetaData, Integer, Boolean, DateTime, Float
from sqlalchemy.ext.declarative import declarative_base
from typing import List

Base = declarative_base()

engine = create_engine('sqlite:///my_database.db', echo=False)


class Figi(Base):
    __tablename__ = 'figi_table'

    figi = Column(String, primary_key=True)
    name = Column(String)
    ticker = Column(String)
    
class HistoricCandleModel(Base):
    __tablename__ = 'historic_candles'

    id = Column(Integer, primary_key=True)
    figi = Column(String)
    open = Column(Float)
    high = Column(Float)
    low = Column(Float)
    close = Column(Float)
    volume = Column(Integer)
    time = Column(DateTime)
    is_complete = Column(Boolean)
    candle_source = Column(Integer)
    interval = Column(Integer)  # Добавлено поле для интервала

def go_db():
    Base.metadata.drop_all(bind=engine)
    Base.metadata.create_all(bind=engine)

if __name__ == "__main__":
    go_db()

